<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /*    8.阶乘  5！   1*2*3*4*5     10！  18！ */


        // 求阶乘函数
        function factorial(n) {
            // 阶乘
            let factorials = 1;
            for (let i = 1; i <= n; i++) {
                factorials *= i;
            }
            return factorials;
        }
        console.log(factorial(5));
        console.log(factorial(10));
        console.log(factorial(18));
    </script>
</body>

</html>